<?php
$this->breadcrumbs=array(
	'Medias',
);

$this->menu=array(
	array('label'=>'Create Media', 'url'=>array('create')),
	array('label'=>'Manage Media', 'url'=>array('admin')),
);
?>

<?php 

	$ready = <<<READY
	$("#product-statistics").css({"height":"120px","overflow":"hidden"});
	
	$("#product-show").toggle(function(){
		$("#product-statistics").css({"height":"auto"}).fadeIn('show');
	},function(){
		$("#product-statistics").css({"height":"120px","overflow":"hidden"});
	});
	
READY;

	$batchResource = $this->createUrl('comment/batchresource');
	$itemview = $this->createUrl('comment/itemview');
	$suffix = Yii::app()->urlManager->urlSuffix;
	

	$head = <<<HEAD

function func_update(id){
	var object = id.parent().siblings(".thumbnail");
	var src = id.attr("id");
	location.href=src;
}

function func_show(id){
	var object = id.parent().siblings(".thumbnail");
	var src = object.find("img").attr("src");
	src = src.replace('_thumb','');
	$.colorbox({href:src,slideshow:true});
	return false;
}

function func_showImg(id){

	var src = id.attr("name");

	title = id.attr("title");
	
	$.colorbox({href:src,title:title, height:'95%'});
	return false;
}

function updateView(id){
	
	var url = '{$itemview}';

	url = url.replace(/{$suffix}/,'/id/'+id+'{$suffix}');

	
//	alert(url);
//	$.get(url,function(msg){
//		alert(msg);
//	});
	
	$("#reply-"+id).load(url);
}
function actionResourceIsComment(object){

	var id = object.attr("id");
	var ac = object.attr("name");

	//alert(id+'-'+ac);
	
	$.post('{$batchResource}',{'id':id,'ac':ac},function(data){
		//alert(data);

		updateView(id);

		if(data == 0){
		    $.msgbox({
		        height:100,
		        width:250,
		        content:{type:'alert', content: '修改成功！'},
		        animation:4,
		        onClose:function(){
					
		        }
		    });
		}	
	});

	
}

HEAD;
?>
<?php Yii::app()->getClientScript()->registerScript('product-index-ready',$ready,CClientScript::POS_READY);?>
<?php Yii::app()->getClientScript()->registerScript('product-index-head',$head,CClientScript::POS_HEAD);?>

<div class="column1">
	<div class="box">
		<?php $this->beginWidget('zii.widgets.CPortlet', array('title'=>Yii::t('admin','Statistics')));?>
			<div class="box-content">
				<ul id="product-statistics">
				<?php foreach ($catelist as $cate):?>
					<?php $this->renderPartial('_list',array('data'=>$cate));?>
				<?php endforeach;?>		
				</ul>
				<div style="text-align: right;"><a id="product-show" href="javascript:void();">显示所有分类</a></div>
			</div>
		<?php $this->endWidget();?>
	</div>		

	<div class="box">
	<?php $this->beginWidget('zii.widgets.CPortlet', array('title'=>Yii::t('admin','Comments')));?>
		<div class="box-content">
			<?php foreach ($comments as $data): ?>
				<?php $this->renderPartial('/comment/_list',array('data'=>$data));?>
			<?php endforeach;?>
			<hr class="space" />
		</div>	
	<?php $this->endWidget();?>
	</div>

</div>
<div class="column2">
	<div class="box">
		<?php $this->beginWidget('zii.widgets.CPortlet', array('title'=>Yii::t('media','Media Info'),	));?>
			<div class="box-content">
				<?php $this->widget('zii.widgets.CListView', array(
					'dataProvider'=>$dataProvider,
					'itemView'=>'_pview',
				)); ?>	
				
				<hr class="space" />
			</div>			
		<?php $this->endWidget();?>
	</div>
	
</div>

<?php $this->widget('ext.box.colorbox.colorboxWidget',array(
		'id'=>'.various1',
		'theme'=>'example1',
//		'options'=>'width:"50%", inline:true, href:"#uploadbox",onClosed:function(){ load(); }'
));?> 
